package com.xrz.sxm.aj.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;

import com.xrz.sxm.aj.activity.Act_FenKe;
import com.xrz.sxm.aj.activity.Act_Main;
import com.xrz.sxm.aj.activity.AnLiQiangqingActivity;
import com.xrz.sxm.aj.activity.R;

public class DrawerAdapter extends BaseAdapter {
	private Context c;
	private List<String> datas = new ArrayList<String>();
	private int type;

	public DrawerAdapter(Context c, List<String> datas, int type) {
		this.c = c;
		this.datas = datas;
		this.type = type;
	}

	@Override
	public int getCount() {
		return datas.size();
	}

	@Override
	public Object getItem(int arg0) {
		return datas.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(final int arg0, View view, ViewGroup arg2) {
		if (view == null) {
			view = LayoutInflater.from(c).inflate(R.layout.item_slide, null);
		}
		final Button btn = (Button) view.findViewById(R.id.btn_zhengzhuang);
		btn.setText(datas.get(arg0));
		btn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View view) {
				if (type == Act_Main.ZHENGZHUANGTYPE) {
					c.startActivity(new Intent(c, Act_FenKe.class).putExtra(
							"data", btn.getText().toString()));
				} else {
					c.startActivity(new Intent(c, AnLiQiangqingActivity.class)
							.putExtra("data", btn.getText().toString()));
				}
			}
		});
		return view;
	}

}
